//  关注作家和取消关注
import axios from "axios";
import { ElMessage } from "element-plus";
import { ref } from "vue";
import { getCurrentInstance } from "vue";
export const guan = async (user_name,proxy) => {
  console.log(user_name);
  try {
    const response = await proxy.$http.post("/loved/", {
      user_name : user_name,
    });
    const res = response.data;
    console.log(res);
    if(res.status === "success"){
      // ElMessage.success("关注成功");
      return true;
    }
    else{
      ElMessage.error("关注失败");
      return false;
    }
  } catch (error) {
    console.error(`Error fetching ${user_name} author:`, error);
    return [];
  }
}

export const dis_guan = async (user_name ,proxy) => {
  console.log(user_name);
  try {
    const response = await proxy.$http.post("/no_loved/", {
      user_name: user_name,
    });
    const res = response.data;
    console.log(res);
    if (res.status === "success") {
      // ElMessage.success("取消关注成功");
      return true;
    } else {
      ElMessage.error("取消关注失败");
      return false;
    }
  } catch (error) {
    console.error(`Error fetching ${user_name} author:`, error);
    return [];
  }
};